home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-02-10 | 4.8 KB | 114 lines | [TEXT/KAHL] |
- NOTES ON THE PORT OF SPIM TO THE MACINTOSH
- ==========================================
-
- Getting it to compile:
- ----------------------
-
- I am starting from the NT Windows port by Scott Rose.
-
- I use the preprocessor symbol MACINTOSH to distinguish Mac OS-specific constructs from
- their Unix or NT equivalents. THINK C provides a way to automatically define this symbol
- in every source file. Users of other compilers might have to insert it by hand.
-
- I eventually realized I had to #define BIGENDIAN in this same automatic manner.
-
- In spim.h, I don't include <sys/types.h>.
-
- In lex_yy.c, I cast the first argument of calls to sscanf() as (char *). This is
- really a change to scanner.l, but I don't have lex.
-
- In run.c, I don't include the X11 stuff, but I do include spim-sys.h and lex_yy.h.
-
- In mem.h, I cast the last argument of calls to bad_mem_read() as (mem_word *).
-
- In spim-uti.c, I make the Mac version import the same things as the NT version, and
- define DEFAULT_TRAP_HANDLER to "trap.handler". I still have to figure out where to
- search for the default handler on the Mac.
-
- In sym_tab.c, the hash table is too big. Instead of a large prime around 8000, I
- will use one around 4000, namely 4001. It might be better to malloc the table at
- run time.
-
- In y_tab.c, I made the argument to yyerror "const" char *. I also changed many
- examples of "yypvt[x] = NULL" to "yypvt[x] = 0". I added a declaration of store_byte().
- I added typedef void (*VoidProc)(), made this the type of store_op, and cast
- store_half() to this type. I changed two more NULLs to 0; do diff against Scott's
- code to find them. I cast the argument to free() as void *.
-
- Once again, I touched y_tab.c because I don't have yacc. The real source file is
- parser.y.
-
- In inst.c, I cast the last argument to qsort() as CompareFunc, which is my own typedef.
-
- I rewrote the memory access macros in mem.h as functions. I rewrote the
- register access macros in reg.h as functions. Code for all of them lives in mem.c.
- Let's get on with it!
-
- With THINK C on a Macintosh II, there is a lengthy delay (more than a minute) after
- compiling run_spim(). The machine is not hung, just doing something non-linear.
-
- Getting it to link:
- -------------------
-
- I get many "multiply defined" errors because of the promiscuous use of external variables.
- I use a trick where the .c file that defines the variables in a .h file must first
- define a symbol. Other .c files including the same .h leave the symbol undefined and
- so get external declarations.
-
- I did the above to mem.h and reg.h.
-
- In spim.h, I simply made console_out and message out external.
-
- In sym_tbl.c, I declared data_dir external.
-
- I had to define bcmp(), bcopy() and bzero(), just as Scott did.
-
- In spim-uti.c, I removed the reference to environ. The Mac has no concept of environ,
- argc, or argv. I declared input_file_name external.
-
- Building an interface:
- ----------------------
-
- THINK C automatically includes several commonly-used header files for Toolbox and OS
- functions, such as QuickDraw, WindowMgr, and the like. Other Mac compilers may require
- these to be explicitely given.
-
- I had to tell THINK C to use "far data", 4-byte ints and 8-byte doubles. I recompiled
- versions of the ANSI and Unix libraries so they had the same characteristics.
-
- The menu and dialog design is based on Scott's NT port. I'm not trying to be any
- fancier than he is.
-
- I ifdeffed out the copyright notice output in spim-uti.c. The Mac has a better way
- to present this information. I also put in a call to MacFatalError(), which is defined
- in macspim.c.
-
- I touched lex_yy.c to make it call fatal_error() (in spim_uti.c) instead of exit().
- This should be in everybody's code.
-
- I wrote my own malloc() and free() routines that try to be smarter about Mac memory
- limitations. I am also finding lots of places where malloc() is called but the
- result is not tested for validity. I fixed this in inst.c and lex_yy.c. I removed
- mem.c from the SPIM flavor of the ANSI library.
-
- I found some more unchecked malloc() calls in sym_tbl.c. The person who decided to
- make malloc() the first argument to strcpy should be shot!
-
- In inst.c, I added a routine to set break_inst back to NULL to force a new malloc.
- I need this after clearing all. Any other static malloc'ed pointers I discover will
- also need to get renullified in this case. A headache, but at least memory isn't
- crashing me anymore.
-
- Testing:
- --------
- It won't run tt.alu.bare.s because that file is for little-endian machines.
-
- The .half directive was broken. Store_half() must have its parameter declared as int,
- not short, because the parser will always pass four bytes to any of the store_x()
- routines. On a big-endian machine, this breaks. (Store_half() is in data.c).
-
- It ran tt.fpu.bar.s and tt.SAL.s without any problems.
-
- In spim_uti.c, I added program_starting_address = 0 to initialize_world(). This is
- probably a bug in everybody's version.
-